package com.meida.module.bus.provider.service;

import com.meida.common.base.entity.EntityMap;
import com.meida.common.mybatis.base.service.IBaseService;
import com.meida.common.mybatis.model.ResultBody;
import com.meida.module.bus.client.entity.BusOrder;
import com.meida.module.bus.client.entity.BusOrderAnswer;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 解答表 接口
 *
 * @author flyme
 * @date 2021-08-03
 */
public interface BusOrderAnswerService extends IBaseService<BusOrderAnswer> {

    /**
     * 学霸出价
     *
     * @param orderId
     * @param scholartyrantId
     * @param quotedPrice
     * @return
     */
    Boolean saveQuotedPrice(Long orderId, Long scholartyrantId, BigDecimal quotedPrice);

    /**
     * 统计某订单报价人数
     *
     * @param orderId
     * @return
     */
    Long countNumByOrderId(Long orderId);

    /**
     * 统计某个学霸某个订单
     *
     * @param orderId
     * @param answerUserId
     * @return
     */
    Long countNumByOrderIdAndUserId(Long orderId, Long answerUserId);


    /**
     * 获取某订单答案
     *
     * @param orderId
     * @param answerUserId
     * @return
     */
    EntityMap getOrderAnswerByOrderIdAndUserId(Long orderId, Long answerUserId);

    /**
     * 查询作业无忧出价列表
     *
     * @param orderId
     * @return
     */
    List<EntityMap> selectHomeWorkOrderAnswerList(Long orderId);


    /**
     * 统计某学霸总答题次数
     *
     * @param answerUserId
     * @return
     */
    Integer countNumByAnswerUserId(Long answerUserId);

    /**
     * 统计某学霸解答状态数量
     *
     * @param answerUserId
     * @param answerState
     * @return
     */
    Long countNumByAnswerUserId(Long answerUserId, Integer answerState);


    /**
     * 设置是否是答案
     *
     * @param answerId
     * @return
     */
    Boolean setIsAnswer(Long answerId);

    /**
     * 设置订单答案已结算
     *
     * @param answerId
     */
    Boolean answerSetIsSettle(Long answerId);

    /**
     * 查询订单答案信息
     *
     * @param orderId
     * @return
     */
    BusOrderAnswer getAnswerByOrderId(Long orderId);

    /**
     * 查询到了结算日期还未结算的订单答案
     *
     * @return
     */
    List<EntityMap> querySettleExpireOrderAnswer();

    /**
     * 佣金结算
     *
     * @param answerId
     */
    void orderAnswerSettleCommission(Long answerId);

    /**
     * 合计学霸已结算佣金
     * @param answerUserId
     * @return
     */
    BigDecimal sumOrderHaveSettleAmount(Long answerUserId);
    /**
     * 合计学霸未结算佣金
     * @param answerUserId
     * @return
     */
    BigDecimal sumOrderHaveNoSettleAmount(Long answerUserId);

    /**
     * 订单假删(逻辑删除)
     *
     * @param orderId
     * @return
     */
    ResultBody deleteById(Long orderId);
}
